#include <bits/stdc++.h>
//#include "head.h"
using namespace std;
using ll = long long;

void solve()
{
    ll n;
    cin >> n;
    vector<ll> v(n);
    ll sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
        sum += v[i];
    }
    if (sum % n == 0)
    {
        ll x = sum / n;
        for (int i = 0; i < n - 2; i++)
        {
            if (v[i] > x)
                v[i + 2] += v[i] - x;
            else if (v[i] < x)
                v[i + 2] -= x - v[i];
            v[i] = x;
        }
        v.resize(distance(v.begin(), unique(v.begin(), v.end())));
        if (v.size() == 1)
        {
            cout << "YES" << endl;
            return;
        }
    }
    cout << "NO" << endl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}